package cn.woochen.comlib.photo

import android.app.Activity
import androidx.fragment.app.Fragment
import com.luck.picture.lib.basic.PictureSelector
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.interfaces.OnExternalPreviewEventListener

object PhotoHelper {

    /**
     * 预览图片
     *
     * @param position
     * @param medias
     */
    fun previewPhoto(fragment: Fragment, position: Int, medias: ArrayList<LocalMedia?>?) {
        PictureSelector.create(fragment)
            .openPreview()
            .setImageEngine(GlideEngine.createGlideEngine())
            .setExternalPreviewEventListener(object : OnExternalPreviewEventListener {
                override fun onPreviewDelete(position: Int) {

                }

                override fun onLongPressDownload(media: LocalMedia?): Boolean {
                    return false
                }
            }).startActivityPreview(position, true, medias)
    }

    /**
     * 预览图片
     * @param position
     * @param medias
     */
    fun previewPhoto(activity: Activity, position: Int, medias: ArrayList<LocalMedia?>?) {
        PictureSelector.create(activity)
            .openPreview()
            .setImageEngine(GlideEngine.createGlideEngine())
            .setExternalPreviewEventListener(object : OnExternalPreviewEventListener {
                override fun onPreviewDelete(position: Int) {

                }

                override fun onLongPressDownload(media: LocalMedia?): Boolean {
                    return false
                }
            }).startActivityPreview(position, true, medias)
    }
}